﻿using CPPEI.App.Console;
using CPPEI.BD.Contract;
using CPPEI.Coolzon.Common.Startup;
using CPPEI.Coolzon.Configuration;
using CPPEI.Net.UDP;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.BD.RemoteLauncher
{
    class Program
    {
        static void Main(string[] args)
        {
            // 初始化配置信息
            XConfigUtil.Init(Environment.Instance, Environment.GetEnvironmentFilePath());
            new App().Run(args);
        }
    }

    class App : XApplication
    {
        UDPClient _udpClient;

        public App()
            : base("CPPEI", "BD", "RemoteLauncher", "RemoteLauncher")
        {
        }

        protected override bool OnXStartup(StartupParamCollection startupParams)
        {
            _udpClient = new UDPClient(Environment.Instance.Port, new ResponseHandlerFactory());
            Net.NetPackage package = new Net.NetPackage(NETCMD.RunDisplay, Net.NetReplayMode.None, 0, new byte[] { 0x01 });
            _udpClient.SendTo(Environment.Instance.TargetIP, package);
            return false;
        }
    }
}
